-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[flang][Semantics] Fix ICE when compiling a mod file with parameter w… #124285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[flang][Semantics] Fix ICE when compiling a mod file with parameter w… #124285
Conversation
…ithout type specified
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-flang-semantics Author: Jean-Didier PAILLEUX (JDPailleux) Changes…ithout type specified Fatal internal error occurred when compiling a mod file with a subroutine which contain a parameter with no Ex: module inform
implicit none
interface normp
module subroutine normt( array, n, val,p )
integer siz
integer,optional::p
real*8 array(*)
real*8 val
end subroutine
end interface
end Full diff: https://github.com/llvm/llvm-project/pull/124285.diff 2 Files Affected:
diff --git a/flang/lib/Semantics/mod-file.cpp b/flang/lib/Semantics/mod-file.cpp
index 51ff70c3ed8341..7a60e22de726e7 100644
--- a/flang/lib/Semantics/mod-file.cpp
+++ b/flang/lib/Semantics/mod-file.cpp
@@ -955,7 +955,13 @@ void ModFileWriter::PutObjectEntity(
}
}
PutEntity(
- os, symbol, [&]() { PutType(os, DEREF(symbol.GetType())); },
+ os, symbol,
+ [&]() {
+ // Need to check if there is a TYPE on this symbol to avoid any ICE
+ if (details.type()) {
+ PutType(os, DEREF(symbol.GetType()));
+ }
+ },
getSymbolAttrsToWrite(symbol));
PutShape(os, details.shape(), '(', ')');
PutShape(os, details.coshape(), '[', ']');
diff --git a/flang/test/Semantics/modfile_missing_type.f90 b/flang/test/Semantics/modfile_missing_type.f90
new file mode 100644
index 00000000000000..fda19372b8993f
--- /dev/null
+++ b/flang/test/Semantics/modfile_missing_type.f90
@@ -0,0 +1,14 @@
+! RUN: %python %S/test_errors.py %s %flang_fc1
+! Test to check that this module can be compiled when an argument has no specified type
+module inform
+ implicit none
+ interface normp
+ module subroutine normt( array,n,val,p )
+ integer siz
+ integer,optional::p
+ real*8 array(*)
+ real*8 val
+ end subroutine
+ end interface
+end
+
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This DEREF is not the bug. The bug is that the symbol has no type after name resolution, but must have one. The DEREF() here is catching the bug, and it must remain in place.
…ithout type specified
Fatal internal error occurred when compiling a mod file with a subroutine which contain a parameter with no
explicit type.
Ex: